package com.gxbadge.authority;

import com.gxbadge.model.Administrator;
import com.opensymphony.xwork2.*;

import com.opensymphony.xwork2.interceptor.*;


public class AdminAuthorityInterceptor extends AbstractInterceptor
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 7281382829241301908L;

	public String intercept(ActionInvocation invocation) throws Exception{
		
		
		ActionContext ctx = ActionContext.getContext();
		Administrator admin = (Administrator)ctx.getSession().get("admin");
		
		//String methodName = invocation.getProxy().getMethod();
		//System.out.println("拦截器------------当前运行的方法名--------"+methodName);
		
		
		if (admin != null && admin.getPermState())
		{
			return invocation.invoke();
		}else
		{
			return Action.LOGIN;
		}
		
	}
}